package com.hxzy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hxzy.dto.ProductSearchDTO;
import com.hxzy.entity.Merchandise;
import com.hxzy.vo.ProductVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商品信息
 * @author Administrator
 */
@Mapper
@Repository
public interface MerchandiseMapper extends BaseMapper<Merchandise> {

    Merchandise selectByPrimaryKey(Long id);


    List<ProductVO> search(@Param(value = "dto") ProductSearchDTO productSearchDTO);

    /**
     * 更新状态
     * @param id
     * @param status
     * @return
     */
    @Update(value = "update merchandise set isgrounding=#{status} where id=#{id}")
    int changeStatus(@Param(value = "id") Long id, @Param(value = "status") Integer status);

    /**
     * 根据商家ID和分类的ID查询菜品列表
     * @param categoryId
     * @param merchantId
     * @return
     */
    List<Merchandise> searchByCategoryAndMerchant(@Param(value = "categoryId")Long categoryId,@Param(value = "merchantId") Long merchantId);
}